<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>06_JS函数</title>
</head>
<body>
<script>
    function f1(){
        console.log("f1被执行了!");
    }
    f1();

    function f2(n){//形参
        console.log("f2被执行了!");
        console.log(n);
    }
    f2(100);//实参
    f2('你好');
    f2(true);

    //函数可以设置多个参数,且参数个数可以不匹配
    //如果实参个数大于形参个数,多余的实参会被舍掉
    //如果实参个数小于形参个数,未被赋值的形参值为undefined
    function f3(x,y){
        console.log("f3被执行了!");
        console.log(x+y);
    }
    f3(100,200);
    f3(1,2,3,4);//1+2
    f3(1);//1+undefined=NaN

    function f4(x,y){
        console.log("f4被执行了!");
        return x+y;
    }
    var res = f4(100,200);
    console.log(res);
    console.log(f4(111,200));


    (function (){
        console.log("匿名函数被执行了!");
    })();

    var f5 = function (){
        console.log("f5被执行了!");
    }
    f5();
    console.log(f5);
    console.log(typeof f5);



</script>
</body>
</html>